import tkinter as tk

K_W = 6
K_H = 3
F_DX = 190
S_DX = 210
T_DX = 240
K_Y = 380

class Key_Dis:
    def __init__(self,root:tk.Tk):
        self.root = root
        self.first_row = ['Q','W','E','R','T','Y','U','I','O','P']
        self.second_row = ['A','S','D','F','G','H','J','K','L']
        self.third_row = ['Z','X','C','V','B','N','M',',']

        # 初始化字母显示
        self.init_key()

    def init_key(self):
        self.key_dict = {}
        # 第一行
        self.first_list = []
        for i in range(len(self.first_row)):
            new_l = tk.Label(self.root,bg="#999999",font=("Arial",10),
                             width=K_W,height=K_H,text=self.first_row[i])
            self.first_list.append(new_l)
            new_l.place(x=i*60+F_DX,y=40+K_Y)
            # 加入字典便于更新颜色
            self.key_dict[self.first_row[i]] = new_l

        # 第二行
        self.second_list = []
        for i in range(len(self.second_row)):
            new_l = tk.Label(self.root, bg="#999999", font=("Arial", 10),
                             width=K_W, height=K_H,
                             text=self.second_row[i])
            self.first_list.append(new_l)
            self.key_dict[self.second_row[i]] = new_l
            new_l.place(x=i * 60 + S_DX, y=100+K_Y)

        # 第三行
        self.third_list = []
        for i in range(len(self.third_row)):
            new_l = tk.Label(self.root,bg="#999999",font=("Arial",10),
                             width=K_W,height=K_H,text=self.third_row[i])
            self.third_list.append(new_l)
            self.key_dict[self.third_row[i]] = new_l
            new_l.place(x=i*60+T_DX,y = 160+K_Y)

    def update_key(self,check_dict:list[list]):
        for item in check_dict:
            if item[1] == 0:
                self.key_dict[item[0].upper()].config(bg="")






